package com.hackerrank.contests.july13.challenges.journeytomars;

import java.math.BigInteger;
import java.util.Scanner;

public class Solution {
	/**
	 * Calculates (b^p)%m recursively
	 * @param b
	 * @param p
	 * @param m
	 * @return (b^p)%m
	 */
	private static long pow(long b, long p, long m) {
		if(p == 0)
			return 1;
		long p2 = pow(b, p / 2, m), v = (p2 * p2) % m;
		if(p % 2 > 0)
			v = (v * b) % m;
		return v;
	}
	/**
	 * Calculates 18 most significant digits of b^p recursively
	 * @param b
	 * @param p
	 * @param m
	 * @return 18 most significant digits of b^p
	 */
	private static long mpow(long b, long p) {
		if(p == 0)
			return 1;
		BigInteger p2 = new BigInteger(Long.toString(mpow(b, p / 2))), v = p2.multiply(p2);
		if(p % 2 > 0)
			v = v.multiply(new BigInteger(Long.toString(b)));
		int l = v.toString().length();
		for(int i = 19; i <= l; i++)
			v = v.divide(BigInteger.TEN);
		return v.longValue();
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		for(int t = 0; t < T; t++) {
			int N = in.nextInt(), K = in.nextInt(), PK = (int)Math.pow(10, K);
			long v = mpow(2, N - 1);
			int l = Long.toString(v).length();
			for(int i = K; i < l; i++)
				v /= 10;
			System.out.println(v + pow(2, N - 1, PK));
		}
	}
}
